package com.ruoyi.information.controller.pc;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.information.domain.pc.SysSet;
import com.ruoyi.information.service.pc.ISysSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * V1.0配置Controller
 *
 * @author ruoyi
 * @date 2023-05-19
 */
@RestController
@RequestMapping("/set")
public class SysSetController extends BaseController {
    @Autowired
    private ISysSetService sysSetService;

    /**
     * 查询V1.0配置列表
     */
    @GetMapping("/list")
    public AjaxResult list(SysSet sysSet) {
        if (sysSet.getSetType() != null) {
            if (sysSet.getSetType() == 5) {
                sysSet.setDr(1L);
            }
        }
        List<SysSet> list = sysSetService.selectSysSetList(sysSet);
        return success(list);
    }


    /**
     * 获取V1.0配置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysSetService.selectSysSetById(id));
    }

    /**
     * 新增V1.0配置
     */
    @PostMapping
    public AjaxResult add(@RequestBody SysSet sysSet) {
        return toAjax(sysSetService.insertSysSet(sysSet));
    }

    /**
     * 修改V1.0配置
     */
    @PutMapping
    public AjaxResult edit(@RequestBody SysSet sysSet) {
        return toAjax(sysSetService.updateSysSet(sysSet));
    }

    /**
     * 删除V1.0配置
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysSetService.deleteSysSetByIds(ids));
    }
}
